<?php
class App_Source_Articles_Entity extends Mozg_Property_Params
{

	public function GetUrl()
	{
		$url = $this->Get('url');
		if (!strlen($url))
		{
			$url = Mozg::Lib('Str')->GetTraslit($this->GetTitle());
			$this->SetUrl($url);
		}

		return $url;
	}

	public function GetMediaId()
	{
		return $this->GetMedia()->GetId();
	}

	public function GetCustomMedia()
	{
		$ids = $this->GetMediaIds();
		array_unshift($ids, $this->GetMedia()->GetId());
		return $ids;
	}

	public function SetCustomMedia(array $ids)
	{
		$id = (int)array_shift($ids);
		$obj = false;
		if ($id)
		{
			$obj = Mozg_Mapper::Get('Media')->GetOne(array('id' => $id));
		}

		$this->SetMedia($obj);
		$this->SetMediaIds($ids);
	}

}